<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> 封装promise </title>
    <script src="./promise.js"></script>
</head>

<body>
    <script>
        let p = new MYPromise((resolve, reject) => {
            // setTimeout(() => {
                resolve('成功aa')
                console.log(111)
            // })
            // reject('失败')
            // throw '失败'
        })
        // let p1 = new MYPromise((resolve, reject) => {
        //     setTimeout(() => {
        //         resolve('成功1')
        //     }, 2000)
        //     // reject('失败')
        //     // throw '失败'
        // })
        // let p2 = new MYPromise((resolve, reject) => {
        //     setTimeout(() => {
        //         resolve('成功2')
        //     }, 1000)
        //     // reject('失败')
        //     // throw '失败'
        // })
        // console.log(p)

        // p.then(res => {
        //     console.log(111)
        // }).catch(err => {
        //     console.log(err)
        // })
            
            p.then(res => {
                console.log(222)
            })
            console.log(333)
    </script>
</body>

</html>